// 对接口进行请求

// 导入request
import request from "./request.js";

// request.get(); 通过request方法请求数据
// 导出创建方法请求数据
export const getUsers = (params) => request({
    method: "get",
    // url: "http://127.0.0.1:3000/users"  request.js里面已经配置过了
    url: "/users",
    params,// 查询字符串传参
});

// 定义编辑用户接口
export const editUser = (id,data) => request({
    method: "put",
    url: `/users/${id}`,
    data,
});

export const getUser = (id) => request({
    method: "get",
    url: `/users/${id}`,
});

export const login = (data)=> request({
    method: "post",
    url: "/users/login",
    data,
});

// 定义添加用户接口
export const addUser = (data)=> request({
    method: "post",
    url: "/users",
    data,
});

// 定义查询用户是否存在接口
export const exist = (params)=> request({
    method: "get",
    url: "/users/exist",
    params,
});

// 定义删除用户接口
export const deleteUser = (id)=> request({
    method: "delete",
    url: `/users/${id}`,
});

// 权限
export const setGroup = (id,data) => request({
    method:'put',
    url:`/users/group/${id}`,
    data,
});

export const UserPassword =(data) =>request({
    method:'put',
    url:'/users/password',
    data
});

export const loginUser =() =>request({
    method:'get',
    url:'/users/logined',
});

export const loginUserPut =(data) =>request({
    method:'put',
    url:'/users/logined',
    data
});

export const UserImg =(data) =>request({
    method:'post',
    url:'/users/avatar',
    data
})